﻿using System;
using System.Reflection;
using WindowsGame.Common.Data;

namespace WindowsGame.Common.Managers
{
	public interface ITextManager
	{
		void Initialize();
		void Initialize(String root);
		void InitializeBuild();
		void InitializeBuild(String assemblyName);
		void LoadContent();

		String BuildVersion { get; }
	}

	public class TextManager : BaseManager, ITextManager
	{
		public void Initialize()
		{
			Initialize(String.Empty);
		}
		public void Initialize(String root)
		{
			BaseData.Initialize(root);
		}
		public void InitializeBuild()
		{
#if !WINDOWS_PHONE
			Assembly assembly = Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly();
#else
			Assembly assembly = Assembly.GetCallingAssembly();
#endif
			// Get AssemblyVersion from calling AssemblyInfo.cs
			InitializeBuild(assembly.FullName);
		}
		public void InitializeBuild(String assemblyName)
		{
			BuildVersion = assemblyName.Split('=')[1].Split(',')[0];
			if (BuildVersion.EndsWith(".0"))
			{
				BuildVersion = BuildVersion.Substring(0, BuildVersion.Length - 2);
			}
		}

		public void LoadContent()
		{
		}

		public String BuildVersion { get; private set; }
	}
}